<template>
  <div class="spotCheck h100">
    <iframe
      class="reports__iframe"
      id="workflow"
      name="myFrame"
      frameborder="0"
      width="100%"
      height="100%"
      ref="iframe"
      :src="iframeUrl"
    ></iframe>
  </div>
</template>

<script>
import {
  getAddressPre,
  getAddressAfter,
} from "@/api/orderManagement/spotCheck.js";
export default {
  props: {},
  data() {
    return {
      //urlPre:'',
      iframeUrl: "", //'http://10.11.228.110:8075/webroot/decision/view/report?viewlet=order%252F%25E6%25B6%2588%25E7%25BC%25BA%25E7%258E%2587.cpt&ref_t=design&ref_c=44ac8eb9-ebac-4190-b7ad-9003aa5c8536',
      //iframeUrl:'https://zsjiss.guangdongwater.com:9872/portal/index.html?_=1646379088878#/',
      //randomNum :Math.floor(Math.random() * 100000), //取随机数，防止IE缓存
      //iframeUrl:`/static/reports/index.html?${this.randomNum}`,
      //iframeUrl:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20171028%2F9a705b62867e4486afc8cbcaf71573e0.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648956754&t=e1ecd1f9b3613f364b97e6d9dbdcc234',
      //iframeUrl:'http://10.11.228.110:8075/webroot/decision/view/report?viewlet=order%252F%25E6%25B6%2588%25E7%25BC%25BA%25E5%258F%258A%25E6%2597%25B6%25E7%258E%2587.cpt&ref_t=design&ref_c=9fa400df-98cc-4233-9646-7bb1db0d8c2d'
    };
  },
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      this.getAddress();
      //this.getAfterAddress()
      //let randomNum = Math.floor(Math.random() * 100000); //取随机数，防止IE缓存
      //this.iframeUrl = `/static/workflow/workflow.html?${randomNum}`;
    },
    getAddress() {
      getAddressPre()
        .then((res) => {
          if (res.code == 200) {
            this.urlPre = res.data;
            this.getAfterAddress();
          }
        })
        .catch((err) => {
          this.$message.error(err.description);
        });
    },
    getAfterAddress() {
      let param = {
        classifyCode: "iframe",
        code: this.$route.name,
      };
      getAddressAfter(param)
        .then((res) => {
          if (res.code == 200) {
            let currentData = res.data.configDetailList.find((item) => {
              return item.appid == this.$store.getters.currentAppInfo.appId;
            });
            this.iframeUrl = this.urlPre + currentData.value;
          }
        })
        .catch((err) => {
          this.$message.error(err.description);
        });
    },
  },
};
</script>

<style lang="less" scoped>
.spotCheck {
  height: 100%;
  .reports__iframe {
    height: 100%;
    min-height: 400px;
  }
}
</style>